import 'package:enjoy_home/utils/http.dart';
import 'package:enjoy_home/utils/toast.dart';
import 'package:flutter/material.dart';

class HomePage extends StatefulWidget {
  const HomePage({Key? key}) : super(key: key);

  @override
  _HomePageState createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  List notifyList = [];

  @override
  void initState() {
    super.initState();
    getNotifyList();
  }

  getNotifyList() async {
    try {
      final res = await http.get('/announcement');

      if (res['code'] != 10000) {
        return ToastUtil.showInfo("请求公告失败！");
      }
      ToastUtil.showInfo("请求公告成功！");
      print(res);
    } catch (e) {
      ToastUtil.showInfo("网络请求错误！");
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Container(
      child: ListView(
        scrollDirection: Axis.vertical,
        children: [
          Container(
            child: TextButton(
              onPressed: () => {
                Navigator.pushNamed(context, '/detail', arguments: {'id': '1'}),
              },
              child: Text('消息详情'),
            ),
          ),
        ],
      ),
    );
  }
}
